# 实现 PathOperationProtocol
from src.lib.pathEngine import WindowsPath, Path
from src.lib.file.error_code import ErrorCode_for_FileOperations
from src.lib.file.enum import NodeType, FileType

import os
import copy

class WindowsPathOperation:
    @staticmethod
    def list_dir(path: WindowsPath) -> tuple[ErrorCode_for_FileOperations, list[WindowsPath]]: 
        assert isinstance(path, WindowsPath)
        if not os.path.exists(path.path):
            return ErrorCode_for_FileOperations.PATH_NOT_EXIST, []
        if not os.path.isdir(path.path):
            return ErrorCode_for_FileOperations.PATH_IS_NOT_DIR, []
        
        items = os.listdir(path.path)
        file_list = []
        for name in items:
            new_path_list = copy.copy(path.pathList)
            new_path_list.append(name)
            file_list.append(path.build_another(path.volume, new_path_list))

        return ErrorCode_for_FileOperations.SUCCESS, file_list
        
    @staticmethod
    def show_node_type(self, path: WindowsPath) -> tuple[ErrorCode_for_FileOperations, NodeType, FileType]:...

    @staticmethod
    def is_dir(self, path: WindowsPath) -> tuple[ErrorCode_for_FileOperations, bool]:...

    @staticmethod
    def mkdir(self, path: WindowsPath) -> tuple[ErrorCode_for_FileOperations, bool]:...
    @staticmethod
    def mkdir_recursive(self, path: WindowsPath) -> tuple[ErrorCode_for_FileOperations, bool]:...

    @staticmethod
    def remove(self, path: WindowsPath) -> tuple[ErrorCode_for_FileOperations, bool]:...
    @staticmethod
    def remove_recursive(self, path: WindowsPath) -> tuple[ErrorCode_for_FileOperations, bool]:...

    @staticmethod
    def mv(self, path: WindowsPath, new_path: WindowsPath) -> tuple[ErrorCode_for_FileOperations, bool]:...

    @staticmethod
    def copy(self, path: WindowsPath, new_path: WindowsPath) -> tuple[ErrorCode_for_FileOperations, bool]:...

    @staticmethod
    def touch(self, path: WindowsPath) -> tuple[ErrorCode_for_FileOperations, bool]:...